package com.myapplication.utils;

import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.widget.TextView;

/**
 * Created by My on 2016/10/19.
 */
public class MarqueeTextView extends TextView {

    public MarqueeTextView(Context context) {
        this(context, null);
    }

    public MarqueeTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MarqueeTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean isFocused() {
        return true;
    }

    public void setText(String text) {
        super.setText(text);
        setHorizontallyScrolling(true);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                setSelected(false);
                setSelected(true);
            }
        }, 2000);
    }

}
